<?php
Namespace Cyfy\Modules\Forms;
use Cyfy\Message;


/**
 * Input hidden element. 
 *
 * @author Dandelion <dandelion8888@gmail.com>
 * @version 0.1
 */
class Hidden extends Input
{
    /**
     * Creates a new input type hidden.
     * @param string Name of the input
     * @param string Value
     */
    function __construct($name, $value = '')
    {
        $this -> name = $name;
        $this -> value = $value;
    }
        
    /**
     * Shows the input
     */
    function __toString()
    {
        $id = ($this -> id) ? "id=\"{$this->id}\"" : "";
        $output = "	<input type=\"hidden\" $id class=\"form-input-{$this->name}\" name=\"{$this->name}\" value=\"{$this->value}\" />";
        return $output;
    }
    
    /**
     * Loads data from post to the object.
     * @return array array(name => value)
     */
    function loadPostData($prefix)
    {
        // load
        $this -> value = $_POST[$prefix . $this -> name];
        
        // security
        $this -> value = strip_tags($this -> value);
        
        return array($this -> name => $this -> value);
    }
}	  